package com.example.amone;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.amone.bean.GroupBean;
import com.example.amone.bean.MenuBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.tv_area)
    TextView tvArea;
    @BindView(R.id.tv_table)
    TextView tvTable;
    @BindView(R.id.rl_menu)
    RecyclerView rlMenu;
    @BindView(R.id.tv_total)
    TextView tvTotal;
    @BindView(R.id.btn_delete)
    Button btnDelete;
    @BindView(R.id.btn_service)
    Button btnService;
    @BindView(R.id.btn_order)
    Button btnOrder;
    @BindView(R.id.menu_group)
    RecyclerView menuGroup;
    @BindView(R.id.rl_all_menu)
    RecyclerView rlAllMenu;

    private Business business;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ButterKnife.bind(this);
        business = new Business(this, menuGroup, rlAllMenu, rlMenu);
        initData();
    }

    private void initData() {

        List<GroupBean> groupBeanList = new ArrayList<>();
        List<MenuBean> menuBeanList = new ArrayList<>();
        for (int i = 0; i < 7; i++) {
            groupBeanList.add(new GroupBean("2131" + i, "热菜" + i, 1));
        }

        for (int j = 0; j < 30; j++) {
            menuBeanList.add(new MenuBean("21314", "热菜3", 1, "3333" + j, "鱼香肉丝" + j, "哈哈哈哈哈哈", 10.43));
        }
        business.setData(groupBeanList, menuBeanList);
    }

    @OnClick({R.id.btn_delete, R.id.btn_service, R.id.btn_order})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_delete:
                business.delete();
                break;
            case R.id.btn_service:
                business.service("12342141");
                break;
            case R.id.btn_order:
                business.order();
                break;
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        ButterKnife.bind(this).unbind();
    }
}
